<?php

	class HTTPStatus{
	
		function __construct($s=200){
			$this->response = $this->status($s);
			$this->header = "HTTP/1.0 $s ".$this->response;
			$this->message = ($s >= 400) ? $this->message($s) : '';
		}
		
		function status($e){
			switch($e){
				// This class should never be called just to send a 200
				case 200:
					return 'OK';
				case 201:
					return 'Created';
				case 202:
					return 'Accepted';
				case 204:
					return 'No Content';
				case 206:
					return 'Partial Content';
				// 30* status should never reach PHP, except maybe...
				case 304:
					return 'Not Modified';
				// From here on are errors
				case 400:
					return 'Bad request';
				case 401:
					return 'Unauthorized';
				case 403:
					return 'Forbidden';
				case 404:
					return 'Not Found';
				case 405:
					return 'Method Not Allowed';
				case 406:
					return 'Not Acceptable';
				case 418:
					return "I'm A Teapot";	
				case 500:
					return "Internal Server Error";
				default:
					return 'Unknown Status';
			}
		}
		
		function message($e){
			switch($e){
				case 400:
					return 'The request contains bad syntax or cannot be fulfilled.';
				case 401:
					return 'Authentication is required.';
				case 403:
					return 'The request was a legal request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference.';
				case 404:
					return 'The requested resource could not be found.';
				case 405:
					return 'A request was made of a resource using a request method not supported by that resource.';
				case 406:
					return 'The HTCPCP server is unable to brew coffee for some reason. The response should indicate a list of acceptable coffee types.';
				case 418:
					return "The HTCPCP server is a teapot. The responding entity MAY be short and stout.";
				case 500:
					return "Oh, crap!";
				default:
					return "The script threw status '$e' and I don't know what it means. Try referring to http://en.wikipedia.org/wiki/List_of_HTTP_status_codes?";
			}
		}	
	}

